/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2018-2019 Erik Moqvist
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/**
 * This file was generated by cantools version 39.4.0 Sat Dec  2 17:22:09 2023.
 */

#include <string.h>

#include "mr418.h"

static inline uint8_t pack_left_shift_u8(
    uint8_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint8_t)((uint8_t)(value << shift) & mask);
}

static inline uint8_t pack_left_shift_u16(
    uint16_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint8_t)((uint8_t)(value << shift) & mask);
}

static inline uint8_t pack_right_shift_u8(
    uint8_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint8_t)((uint8_t)(value >> shift) & mask);
}

static inline uint8_t pack_right_shift_u16(
    uint16_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint8_t)((uint8_t)(value >> shift) & mask);
}

static inline uint8_t unpack_left_shift_u8(
    uint8_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint8_t)((uint8_t)(value & mask) << shift);
}

static inline uint16_t unpack_left_shift_u16(
    uint8_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint16_t)((uint16_t)(value & mask) << shift);
}

static inline uint8_t unpack_right_shift_u8(
    uint8_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint8_t)((uint8_t)(value & mask) >> shift);
}

static inline uint16_t unpack_right_shift_u16(
    uint8_t value,
    uint8_t shift,
    uint8_t mask)
{
    return (uint16_t)((uint16_t)(value & mask) >> shift);
}

int mr418_veh_info2_pack(
    uint8_t *dst_p,
    const struct mr418_veh_info2_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    memset(&dst_p[0], 0, 8);

    dst_p[0] |= pack_left_shift_u8(src_p->gear_state_now, 4u, 0x70u);
    dst_p[0] |= pack_left_shift_u8(src_p->gear_sta_now_v, 3u, 0x08u);
    dst_p[1] |= pack_left_shift_u8(src_p->ign_state_v, 5u, 0x20u);
    dst_p[1] |= pack_left_shift_u8(src_p->ign_state, 4u, 0x10u);

    return (8);
}

int mr418_veh_info2_unpack(
    struct mr418_veh_info2_t *dst_p,
    const uint8_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    dst_p->gear_state_now = unpack_right_shift_u8(src_p[0], 4u, 0x70u);
    dst_p->gear_sta_now_v = unpack_right_shift_u8(src_p[0], 3u, 0x08u);
    dst_p->ign_state_v = unpack_right_shift_u8(src_p[1], 5u, 0x20u);
    dst_p->ign_state = unpack_right_shift_u8(src_p[1], 4u, 0x10u);

    return (0);
}

int mr418_veh_info2_init(struct mr418_veh_info2_t *msg_p)
{
    if (msg_p == NULL) return -1;

    memset(msg_p, 0, sizeof(struct mr418_veh_info2_t));

    return 0;
}

uint8_t mr418_veh_info2_gear_state_now_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_veh_info2_gear_state_now_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_veh_info2_gear_state_now_is_in_range(uint8_t value)
{
    return (value <= 7u);
}

uint8_t mr418_veh_info2_gear_sta_now_v_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_veh_info2_gear_sta_now_v_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_veh_info2_gear_sta_now_v_is_in_range(uint8_t value)
{
    return (value <= 1u);
}

uint8_t mr418_veh_info2_ign_state_v_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_veh_info2_ign_state_v_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_veh_info2_ign_state_v_is_in_range(uint8_t value)
{
    return (value <= 1u);
}

uint8_t mr418_veh_info2_ign_state_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_veh_info2_ign_state_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_veh_info2_ign_state_is_in_range(uint8_t value)
{
    return (value <= 1u);
}

int mr418_veh_info1_pack(
    uint8_t *dst_p,
    const struct mr418_veh_info1_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    memset(&dst_p[0], 0, 8);

    dst_p[0] |= pack_left_shift_u8(src_p->veh_speed_v, 7u, 0x80u);
    dst_p[0] |= pack_left_shift_u8(src_p->yaw_rat_v, 6u, 0x40u);
    dst_p[0] |= pack_left_shift_u8(src_p->str_angle_v, 5u, 0x20u);
    dst_p[0] |= pack_right_shift_u16(src_p->changcheng_vehicle_spd, 8u, 0x1fu);
    dst_p[1] |= pack_left_shift_u16(src_p->changcheng_vehicle_spd, 0u, 0xffu);
    dst_p[2] |= pack_right_shift_u16(src_p->changcheng_yaw_rate, 8u, 0xffu);
    dst_p[3] |= pack_left_shift_u16(src_p->changcheng_yaw_rate, 0u, 0xffu);
    dst_p[4] |= pack_right_shift_u16(src_p->str_angle, 8u, 0xffu);
    dst_p[5] |= pack_left_shift_u16(src_p->str_angle, 0u, 0xffu);

    return (8);
}

int mr418_veh_info1_unpack(
    struct mr418_veh_info1_t *dst_p,
    const uint8_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    dst_p->veh_speed_v = unpack_right_shift_u8(src_p[0], 7u, 0x80u);
    dst_p->yaw_rat_v = unpack_right_shift_u8(src_p[0], 6u, 0x40u);
    dst_p->str_angle_v = unpack_right_shift_u8(src_p[0], 5u, 0x20u);
    dst_p->changcheng_vehicle_spd = unpack_left_shift_u16(src_p[0], 8u, 0x1fu);
    dst_p->changcheng_vehicle_spd |= unpack_right_shift_u16(src_p[1], 0u, 0xffu);
    dst_p->changcheng_yaw_rate = unpack_left_shift_u16(src_p[2], 8u, 0xffu);
    dst_p->changcheng_yaw_rate |= unpack_right_shift_u16(src_p[3], 0u, 0xffu);
    dst_p->str_angle = unpack_left_shift_u16(src_p[4], 8u, 0xffu);
    dst_p->str_angle |= unpack_right_shift_u16(src_p[5], 0u, 0xffu);

    return (0);
}

int mr418_veh_info1_init(struct mr418_veh_info1_t *msg_p)
{
    if (msg_p == NULL) return -1;

    memset(msg_p, 0, sizeof(struct mr418_veh_info1_t));

    return 0;
}

uint8_t mr418_veh_info1_veh_speed_v_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_veh_info1_veh_speed_v_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_veh_info1_veh_speed_v_is_in_range(uint8_t value)
{
    return (value <= 1u);
}

uint8_t mr418_veh_info1_yaw_rat_v_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_veh_info1_yaw_rat_v_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_veh_info1_yaw_rat_v_is_in_range(uint8_t value)
{
    return (value <= 1u);
}

uint8_t mr418_veh_info1_str_angle_v_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_veh_info1_str_angle_v_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_veh_info1_str_angle_v_is_in_range(uint8_t value)
{
    return (value <= 1u);
}

uint16_t mr418_veh_info1_changcheng_vehicle_spd_encode(double value)
{
    return (uint16_t)(value / 0.05625);
}

double mr418_veh_info1_changcheng_vehicle_spd_decode(uint16_t value)
{
    return ((double)value * 0.05625);
}

bool mr418_veh_info1_changcheng_vehicle_spd_is_in_range(uint16_t value)
{
    return (value <= 5333u);
}

uint16_t mr418_veh_info1_changcheng_yaw_rate_encode(double value)
{
    return (uint16_t)((value - -2.093) / 0.00024);
}

double mr418_veh_info1_changcheng_yaw_rate_decode(uint16_t value)
{
    return (((double)value * 0.00024) + -2.093);
}

bool mr418_veh_info1_changcheng_yaw_rate_is_in_range(uint16_t value)
{
    return (value <= 17442u);
}

uint16_t mr418_veh_info1_str_angle_encode(double value)
{
    return (uint16_t)((value - -900.0) / 0.1);
}

double mr418_veh_info1_str_angle_decode(uint16_t value)
{
    return (((double)value * 0.1) + -900.0);
}

bool mr418_veh_info1_str_angle_is_in_range(uint16_t value)
{
    return (value <= 18000u);
}

int mr418_quality_information_pack(
    uint8_t *dst_p,
    const struct mr418_quality_information_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    memset(&dst_p[0], 0, 8);

    dst_p[0] |= pack_left_shift_u8(src_p->id, 0u, 0xffu);
    dst_p[1] |= pack_left_shift_u8(src_p->snr, 0u, 0xffu);
    dst_p[2] |= pack_left_shift_u8(src_p->dis_lon_rms, 3u, 0xf8u);
    dst_p[2] |= pack_right_shift_u8(src_p->vrel_lon_rms, 2u, 0x07u);
    dst_p[3] |= pack_left_shift_u8(src_p->vrel_lon_rms, 6u, 0xc0u);
    dst_p[3] |= pack_left_shift_u8(src_p->dis_lat_rms, 1u, 0x3eu);
    dst_p[3] |= pack_right_shift_u8(src_p->vrel_lat_rms, 4u, 0x01u);
    dst_p[4] |= pack_left_shift_u8(src_p->vrel_lat_rms, 4u, 0xf0u);
    dst_p[4] |= pack_left_shift_u8(src_p->prob_of_exist, 1u, 0x0eu);
    dst_p[4] |= pack_right_shift_u8(src_p->meas_state, 1u, 0x01u);
    dst_p[5] |= pack_left_shift_u8(src_p->meas_state, 7u, 0x80u);
    dst_p[5] |= pack_right_shift_u16(src_p->age, 5u, 0x7fu);
    dst_p[6] |= pack_left_shift_u16(src_p->age, 3u, 0xf8u);
    dst_p[6] |= pack_right_shift_u16(src_p->count, 8u, 0x07u);
    dst_p[7] |= pack_left_shift_u16(src_p->count, 0u, 0xffu);

    return (8);
}

int mr418_quality_information_unpack(
    struct mr418_quality_information_t *dst_p,
    const uint8_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    dst_p->id = unpack_right_shift_u8(src_p[0], 0u, 0xffu);
    dst_p->snr = unpack_right_shift_u8(src_p[1], 0u, 0xffu);
    dst_p->dis_lon_rms = unpack_right_shift_u8(src_p[2], 3u, 0xf8u);
    dst_p->vrel_lon_rms = unpack_left_shift_u8(src_p[2], 2u, 0x07u);
    dst_p->vrel_lon_rms |= unpack_right_shift_u8(src_p[3], 6u, 0xc0u);
    dst_p->dis_lat_rms = unpack_right_shift_u8(src_p[3], 1u, 0x3eu);
    dst_p->vrel_lat_rms = unpack_left_shift_u8(src_p[3], 4u, 0x01u);
    dst_p->vrel_lat_rms |= unpack_right_shift_u8(src_p[4], 4u, 0xf0u);
    dst_p->prob_of_exist = unpack_right_shift_u8(src_p[4], 1u, 0x0eu);
    dst_p->meas_state = unpack_left_shift_u8(src_p[4], 1u, 0x01u);
    dst_p->meas_state |= unpack_right_shift_u8(src_p[5], 7u, 0x80u);
    dst_p->age = unpack_left_shift_u16(src_p[5], 5u, 0x7fu);
    dst_p->age |= unpack_right_shift_u16(src_p[6], 3u, 0xf8u);
    dst_p->count = unpack_left_shift_u16(src_p[6], 8u, 0x07u);
    dst_p->count |= unpack_right_shift_u16(src_p[7], 0u, 0xffu);

    return (0);
}

int mr418_quality_information_init(struct mr418_quality_information_t *msg_p)
{
    if (msg_p == NULL) return -1;

    memset(msg_p, 0, sizeof(struct mr418_quality_information_t));

    return 0;
}

uint8_t mr418_quality_information_id_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_quality_information_id_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_quality_information_id_is_in_range(uint8_t value)
{
    (void)value;

    return (true);
}

uint8_t mr418_quality_information_snr_encode(double value)
{
    return (uint8_t)((value - 7.0) / 0.3125);
}

double mr418_quality_information_snr_decode(uint8_t value)
{
    return (((double)value * 0.3125) + 7.0);
}

bool mr418_quality_information_snr_is_in_range(uint8_t value)
{
    (void)value;

    return (true);
}

uint8_t mr418_quality_information_dis_lon_rms_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_quality_information_dis_lon_rms_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_quality_information_dis_lon_rms_is_in_range(uint8_t value)
{
    return (value <= 31u);
}

uint8_t mr418_quality_information_vrel_lon_rms_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_quality_information_vrel_lon_rms_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_quality_information_vrel_lon_rms_is_in_range(uint8_t value)
{
    return (value <= 31u);
}

uint8_t mr418_quality_information_dis_lat_rms_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_quality_information_dis_lat_rms_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_quality_information_dis_lat_rms_is_in_range(uint8_t value)
{
    return (value <= 31u);
}

uint8_t mr418_quality_information_vrel_lat_rms_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_quality_information_vrel_lat_rms_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_quality_information_vrel_lat_rms_is_in_range(uint8_t value)
{
    return (value <= 31u);
}

uint8_t mr418_quality_information_prob_of_exist_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_quality_information_prob_of_exist_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_quality_information_prob_of_exist_is_in_range(uint8_t value)
{
    return (value <= 7u);
}

uint8_t mr418_quality_information_meas_state_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_quality_information_meas_state_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_quality_information_meas_state_is_in_range(uint8_t value)
{
    return (value <= 3u);
}

uint16_t mr418_quality_information_age_encode(double value)
{
    return (uint16_t)(value);
}

double mr418_quality_information_age_decode(uint16_t value)
{
    return ((double)value);
}

bool mr418_quality_information_age_is_in_range(uint16_t value)
{
    return (value <= 4095u);
}

uint16_t mr418_quality_information_count_encode(double value)
{
    return (uint16_t)(value);
}

double mr418_quality_information_count_decode(uint16_t value)
{
    return ((double)value);
}

bool mr418_quality_information_count_is_in_range(uint16_t value)
{
    return (value <= 2047u);
}

int mr418_extended_information_pack(
    uint8_t *dst_p,
    const struct mr418_extended_information_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    memset(&dst_p[0], 0, 8);

    dst_p[0] |= pack_left_shift_u8(src_p->id, 0u, 0xffu);
    dst_p[1] |= pack_right_shift_u16(src_p->orientation_angle, 2u, 0xffu);
    dst_p[2] |= pack_left_shift_u16(src_p->orientation_angle, 6u, 0xc0u);
    dst_p[2] |= pack_left_shift_u8(src_p->corner_rel_len, 0u, 0x3fu);
    dst_p[3] |= pack_left_shift_u8(src_p->corner_rel_wid, 3u, 0xf8u);
    dst_p[3] |= pack_left_shift_u8(src_p->classz, 0u, 0x07u);
    dst_p[4] |= pack_left_shift_u8(src_p->length, 0u, 0xffu);
    dst_p[5] |= pack_left_shift_u8(src_p->width, 3u, 0xf8u);
    dst_p[5] |= pack_right_shift_u16(src_p->arel_lon, 7u, 0x07u);
    dst_p[6] |= pack_left_shift_u16(src_p->arel_lon, 1u, 0xfeu);
    dst_p[6] |= pack_right_shift_u16(src_p->arel_lat, 8u, 0x01u);
    dst_p[7] |= pack_left_shift_u16(src_p->arel_lat, 0u, 0xffu);

    return (8);
}

int mr418_extended_information_unpack(
    struct mr418_extended_information_t *dst_p,
    const uint8_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    dst_p->id = unpack_right_shift_u8(src_p[0], 0u, 0xffu);
    dst_p->orientation_angle = unpack_left_shift_u16(src_p[1], 2u, 0xffu);
    dst_p->orientation_angle |= unpack_right_shift_u16(src_p[2], 6u, 0xc0u);
    dst_p->corner_rel_len = unpack_right_shift_u8(src_p[2], 0u, 0x3fu);
    dst_p->corner_rel_wid = unpack_right_shift_u8(src_p[3], 3u, 0xf8u);
    dst_p->classz = unpack_right_shift_u8(src_p[3], 0u, 0x07u);
    dst_p->length = unpack_right_shift_u8(src_p[4], 0u, 0xffu);
    dst_p->width = unpack_right_shift_u8(src_p[5], 3u, 0xf8u);
    dst_p->arel_lon = unpack_left_shift_u16(src_p[5], 7u, 0x07u);
    dst_p->arel_lon |= unpack_right_shift_u16(src_p[6], 1u, 0xfeu);
    dst_p->arel_lat = unpack_left_shift_u16(src_p[6], 8u, 0x01u);
    dst_p->arel_lat |= unpack_right_shift_u16(src_p[7], 0u, 0xffu);

    return (0);
}

int mr418_extended_information_init(struct mr418_extended_information_t *msg_p)
{
    if (msg_p == NULL) return -1;

    memset(msg_p, 0, sizeof(struct mr418_extended_information_t));

    return 0;
}

uint8_t mr418_extended_information_id_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_extended_information_id_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_extended_information_id_is_in_range(uint8_t value)
{
    (void)value;

    return (true);
}

uint16_t mr418_extended_information_orientation_angle_encode(double value)
{
    return (uint16_t)((value - -180.0) / 0.4);
}

double mr418_extended_information_orientation_angle_decode(uint16_t value)
{
    return (((double)value * 0.4) + -180.0);
}

bool mr418_extended_information_orientation_angle_is_in_range(uint16_t value)
{
    return (value <= 900u);
}

uint8_t mr418_extended_information_corner_rel_len_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_extended_information_corner_rel_len_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_extended_information_corner_rel_len_is_in_range(uint8_t value)
{
    return (value <= 63u);
}

uint8_t mr418_extended_information_corner_rel_wid_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_extended_information_corner_rel_wid_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_extended_information_corner_rel_wid_is_in_range(uint8_t value)
{
    return (value <= 31u);
}

uint8_t mr418_extended_information_classz_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_extended_information_classz_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_extended_information_classz_is_in_range(uint8_t value)
{
    return (value <= 7u);
}

uint8_t mr418_extended_information_length_encode(double value)
{
    return (uint8_t)(value / 0.1);
}

double mr418_extended_information_length_decode(uint8_t value)
{
    return ((double)value * 0.1);
}

bool mr418_extended_information_length_is_in_range(uint8_t value)
{
    (void)value;

    return (true);
}

uint8_t mr418_extended_information_width_encode(double value)
{
    return (uint8_t)(value / 0.1);
}

double mr418_extended_information_width_decode(uint8_t value)
{
    return ((double)value * 0.1);
}

bool mr418_extended_information_width_is_in_range(uint8_t value)
{
    return (value <= 31u);
}

uint16_t mr418_extended_information_arel_lon_encode(double value)
{
    return (uint16_t)((value - -10.0) / 0.02);
}

double mr418_extended_information_arel_lon_decode(uint16_t value)
{
    return (((double)value * 0.02) + -10.0);
}

bool mr418_extended_information_arel_lon_is_in_range(uint16_t value)
{
    return (value <= 1023u);
}

uint16_t mr418_extended_information_arel_lat_encode(double value)
{
    return (uint16_t)((value - -5.0) / 0.02);
}

double mr418_extended_information_arel_lat_decode(uint16_t value)
{
    return (((double)value * 0.02) + -5.0);
}

bool mr418_extended_information_arel_lat_is_in_range(uint16_t value)
{
    return (value <= 511u);
}

int mr418_general_information_pack(
    uint8_t *dst_p,
    const struct mr418_general_information_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    memset(&dst_p[0], 0, 8);

    dst_p[0] |= pack_left_shift_u8(src_p->id, 0u, 0xffu);
    dst_p[1] |= pack_right_shift_u16(src_p->dist_lon, 4u, 0xffu);
    dst_p[2] |= pack_left_shift_u16(src_p->dist_lon, 4u, 0xf0u);
    dst_p[2] |= pack_right_shift_u16(src_p->dist_lat, 8u, 0x0fu);
    dst_p[3] |= pack_left_shift_u16(src_p->dist_lat, 0u, 0xffu);
    dst_p[4] |= pack_right_shift_u16(src_p->vrel_lon, 3u, 0xffu);
    dst_p[5] |= pack_left_shift_u16(src_p->vrel_lon, 5u, 0xe0u);
    dst_p[5] |= pack_right_shift_u16(src_p->vrel_lat, 5u, 0x1fu);
    dst_p[6] |= pack_left_shift_u16(src_p->vrel_lat, 3u, 0xf8u);
    dst_p[6] |= pack_left_shift_u8(src_p->dyn_prop, 0u, 0x07u);
    dst_p[7] |= pack_left_shift_u8(src_p->rcs, 0u, 0xffu);

    return (8);
}

int mr418_general_information_unpack(
    struct mr418_general_information_t *dst_p,
    const uint8_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    dst_p->id = unpack_right_shift_u8(src_p[0], 0u, 0xffu);
    dst_p->dist_lon = unpack_left_shift_u16(src_p[1], 4u, 0xffu);
    dst_p->dist_lon |= unpack_right_shift_u16(src_p[2], 4u, 0xf0u);
    dst_p->dist_lat = unpack_left_shift_u16(src_p[2], 8u, 0x0fu);
    dst_p->dist_lat |= unpack_right_shift_u16(src_p[3], 0u, 0xffu);
    dst_p->vrel_lon = unpack_left_shift_u16(src_p[4], 3u, 0xffu);
    dst_p->vrel_lon |= unpack_right_shift_u16(src_p[5], 5u, 0xe0u);
    dst_p->vrel_lat = unpack_left_shift_u16(src_p[5], 5u, 0x1fu);
    dst_p->vrel_lat |= unpack_right_shift_u16(src_p[6], 3u, 0xf8u);
    dst_p->dyn_prop = unpack_right_shift_u8(src_p[6], 0u, 0x07u);
    dst_p->rcs = unpack_right_shift_u8(src_p[7], 0u, 0xffu);

    return (0);
}

int mr418_general_information_init(struct mr418_general_information_t *msg_p)
{
    if (msg_p == NULL) return -1;

    memset(msg_p, 0, sizeof(struct mr418_general_information_t));

    return 0;
}

uint8_t mr418_general_information_id_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_general_information_id_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_general_information_id_is_in_range(uint8_t value)
{
    (void)value;

    return (true);
}

uint16_t mr418_general_information_dist_lon_encode(double value)
{
    return (uint16_t)(value / 0.125);
}

double mr418_general_information_dist_lon_decode(uint16_t value)
{
    return ((double)value * 0.125);
}

bool mr418_general_information_dist_lon_is_in_range(uint16_t value)
{
    return (value <= 4095u);
}

uint16_t mr418_general_information_dist_lat_encode(double value)
{
    return (uint16_t)((value - -102.4) / 0.05);
}

double mr418_general_information_dist_lat_decode(uint16_t value)
{
    return (((double)value * 0.05) + -102.4);
}

bool mr418_general_information_dist_lat_is_in_range(uint16_t value)
{
    return (value <= 4095u);
}

uint16_t mr418_general_information_vrel_lon_encode(double value)
{
    return (uint16_t)((value - -120.0) / 0.1);
}

double mr418_general_information_vrel_lon_decode(uint16_t value)
{
    return (((double)value * 0.1) + -120.0);
}

bool mr418_general_information_vrel_lon_is_in_range(uint16_t value)
{
    return (value <= 2047u);
}

uint16_t mr418_general_information_vrel_lat_encode(double value)
{
    return (uint16_t)((value - -64.0) / 0.125);
}

double mr418_general_information_vrel_lat_decode(uint16_t value)
{
    return (((double)value * 0.125) + -64.0);
}

bool mr418_general_information_vrel_lat_is_in_range(uint16_t value)
{
    return (value <= 596u);
}

uint8_t mr418_general_information_dyn_prop_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_general_information_dyn_prop_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_general_information_dyn_prop_is_in_range(uint8_t value)
{
    return (value <= 7u);
}

uint8_t mr418_general_information_rcs_encode(double value)
{
    return (uint8_t)((value - -64.0) / 0.5);
}

double mr418_general_information_rcs_decode(uint8_t value)
{
    return (((double)value * 0.5) + -64.0);
}

bool mr418_general_information_rcs_is_in_range(uint8_t value)
{
    (void)value;

    return (true);
}

int mr418_track_list_status_pack(
    uint8_t *dst_p,
    const struct mr418_track_list_status_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    memset(&dst_p[0], 0, 8);

    dst_p[0] |= pack_left_shift_u8(src_p->object_nof_objects, 0u, 0xffu);
    dst_p[1] |= pack_right_shift_u16(src_p->object_meas_counter, 8u, 0xffu);
    dst_p[2] |= pack_left_shift_u16(src_p->object_meas_counter, 0u, 0xffu);
    dst_p[3] |= pack_left_shift_u8(src_p->object_interface_version, 4u, 0xf0u);

    return (8);
}

int mr418_track_list_status_unpack(
    struct mr418_track_list_status_t *dst_p,
    const uint8_t *src_p,
    size_t size)
{
    if (size < 8u) {
        return (-EINVAL);
    }

    dst_p->object_nof_objects = unpack_right_shift_u8(src_p[0], 0u, 0xffu);
    dst_p->object_meas_counter = unpack_left_shift_u16(src_p[1], 8u, 0xffu);
    dst_p->object_meas_counter |= unpack_right_shift_u16(src_p[2], 0u, 0xffu);
    dst_p->object_interface_version = unpack_right_shift_u8(src_p[3], 4u, 0xf0u);

    return (0);
}

int mr418_track_list_status_init(struct mr418_track_list_status_t *msg_p)
{
    if (msg_p == NULL) return -1;

    memset(msg_p, 0, sizeof(struct mr418_track_list_status_t));

    return 0;
}

uint8_t mr418_track_list_status_object_nof_objects_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_track_list_status_object_nof_objects_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_track_list_status_object_nof_objects_is_in_range(uint8_t value)
{
    (void)value;

    return (true);
}

uint16_t mr418_track_list_status_object_meas_counter_encode(double value)
{
    return (uint16_t)(value);
}

double mr418_track_list_status_object_meas_counter_decode(uint16_t value)
{
    return ((double)value);
}

bool mr418_track_list_status_object_meas_counter_is_in_range(uint16_t value)
{
    (void)value;

    return (true);
}

uint8_t mr418_track_list_status_object_interface_version_encode(double value)
{
    return (uint8_t)(value);
}

double mr418_track_list_status_object_interface_version_decode(uint8_t value)
{
    return ((double)value);
}

bool mr418_track_list_status_object_interface_version_is_in_range(uint8_t value)
{
    return (value <= 15u);
}
